import request from '@/utils/request';

/**
 * 分类列表查询
 * @param params 查询条件
 */

export async function cardUsageRecordList(params) {
  const res = await request.get('/massage/cardUsageRecord/page', {
    params
  });
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 头部查询字段查询
 * @param params 查询条件
 */

export async function getCardUsageRecord(params) {
  const res = await request.get('/massage/cardUsageRecord/cardRollStatistics', {
    params
  });

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 卡券删除
 * @param params 查询条件
 */

export async function cardUsageRecordDelete(id) {
  const res = await request.delete('/massage/cardUsageRecord/' + id);
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 批量删除卡券
 * @param params 查询条件
 */

export async function cardUsageRecordBatchDelete(data) {
  const res = await request.delete('/massage/cardUsageRecord/batch', {
    data
  });
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
